//
//  DCFLoginInputView.m
//  DCFactory
//
//  Created by 吴文拼 on 2018/3/30.
//  Copyright © 2018年 吴文拼. All rights reserved.
//

#import "DCFLoginInputView.h"

@interface DCFLoginInputView()<UITextFieldDelegate>

@property (nonatomic , strong)UIView *lineView;

@end

@implementation DCFLoginInputView

-(instancetype)initWithPlaceText:(NSString *)placeText{
    if (self = [super init]) {
        self.clipsToBounds = YES;
        [self addSubview:self.inputTextField];
        self.inputTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeText attributes:@{NSForegroundColorAttributeName:RGBCOLOR(201, 201, 201),NSFontAttributeName:GetFontWithSize(15)}];
        [_inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-12);
            make.left.equalTo(self);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(251, 27)]);
        }];
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = RGBCOLOR(238, 238, 238);
        _lineView = lineView;
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.bottom.equalTo(self);
            make.height.equalTo(@1);
            make.width.equalTo(self);
        }];
    }
    return self;
}

-(DCFTextField *)inputTextField{
    if (!_inputTextField) {
        _inputTextField = [[DCFTextField alloc] init];
        _inputTextField.textColor = RGBCOLOR(51, 51, 51);
        _inputTextField.font = [UIFont systemFontOfSize:15.0f];
        _inputTextField.tintColor = kMainColor;
        _inputTextField.delegate = self;
    }
    return _inputTextField;
}

-(void)textFieldDidBeginEditing:(UITextField *)textField{
    _lineView.backgroundColor = kMainColor;
}

-(void)textFieldDidEndEditing:(UITextField *)textField{
    _lineView.backgroundColor = RGBCOLOR(238, 238, 238);
}

-(void)setKeyboardType:(UIKeyboardType)keyboardType{
    self.inputTextField.keyboardType = keyboardType;
}

-(void)setPlaceText:(NSString *)placeText{
    self.inputTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeText attributes:@{NSForegroundColorAttributeName:RGBCOLOR(201, 201, 201),NSFontAttributeName:GetFontWithSize(15)}];
}

@end
